/**
 * 
 */
package com.cqan.product.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.cqan.entity.pk.LongEntity;

/**
 * @Description TODO
 * @author slaton.wu@gmail.com
 * @date 2012-7-5下午3:09:51
 *
 */
@Entity
//表名与类名不相同时重新定义表名.
@Table(name = "TBL_PRODUCT")
//默认的缓存策略.
@SuppressWarnings("serial")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Product extends LongEntity{

	private Date createTime;
	
	private String description;
	
	private String name;
	
	private boolean status;
	
	private String logo;
	
	private ProductType productType;
	
	
	@Column(name="PRODUCT_TYPE")
	@Enumerated(EnumType.STRING)
	public ProductType getProductType() {
		return productType;
	}


	public void setProductType(ProductType productType) {
		this.productType = productType;
	}

	public enum ProductType{
		
		ANDROID,IPAD,IPHONE,WINDOWS,OTHER;
		
		public String getLabel(){
			switch (this) {
			case ANDROID:
				
				return "安卓";

			case IPAD:
				return "IPAD";
				
			case IPHONE:
				return "IPHONE";
			
			case WINDOWS:
				return "WINDOWS";
				
			case OTHER:
				return "其他";
			}
			return "未知";
		}
	}
	
	
	@Column(name="LOGO")
	public String getLogo() {
		return logo;
	}


	public void setLogo(String logo) {
		this.logo = logo;
	}
	
	@Column(name = "CREATE_TIME")
	public Date getCreateTime() {
		return createTime;
	}

	@Column(name = "DESCRIPTION")
	public String getDescription() {
		return description;
	}

	@Column(name = "NAME")
	public String getName() {
		return name;
	}

	@Column(name = "STATUS")
	public boolean isStatus() {
		return status;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}
	
	@Override
	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}
	
}
